<?php

namespace App\Http\Resources\Admin;

use App\Http\Resources\BaseResource;

class AdminMenusResource extends BaseResource
{
    /**
     * Transform the resource collection into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'name' => $this->name,
            'link' => $this->link,
            'icon' => $this->icon,
            'key' => $this->key,
            'children' => AdminMenusResource::collection($this->whenLoaded('children')),
        ];
    }
}
